package com.sl.au.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sl.au.entity.Division;
import com.sl.au.repository.DivisionRepository;

/**
 * 集合的层级显示
 * 
 * @author HeGuangChuan
 *
 */
@Service
public class ListShowServiceImpl {

	@Autowired
	private DivisionRepository divisionRepository;
	public List<Division> getDivisionList(String str, List<Division> emptyList, List<Division> parents) {
		
		for (Division division : parents) {
			String divisionName = division.getDivisionName();
			division.setDivisionName(str + divisionName);
			emptyList.add(division);
			List<Division> children = divisionRepository.getDivisionsByParent(division.getId());
			if (children != null && children.size() > 0) {
				getDivisionList("　　", emptyList, children);
			}
		}
		return emptyList;
	}


}
